<template>
  <u-container-layout>
    <zlrt-table :p="ctx">
      <template #before>
        <zlrt-search :p="ctx">
          <!-- <template #warehouseName>
            <el-select v-model="ctx.filter.warehouseId">
              <el-option v-for="item in warehouseOptions" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
          </template> -->
          <template #ownerName>
            <el-select v-model="ctx.filter.ownerId">
              <el-option v-for="item in ownerOptions" :key="item.id" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </template>
          <template #skuName>
            <el-input v-model="ctx.otherFilter.skuName" placeholder="请输入物料名称" />
          </template>
        </zlrt-search>
        <div class="tool-bar">
          <!-- <el-button type="danger" v-hasPermit="['wms-warehouse:inventory:del']" icon="Delete" :disabled="!ctx.selected.length"
            @click="ctx.batchDelete()">
            批量删除
          </el-button> -->
          <span style="float:right;margin-bottom: 10px;">
            <el-button type="success" v-hasPermit="['wms-warehouse:inventory:list']" :loading="ctx.exportLoading"
              icon="Download" @click="ctx.export()">
              导出
            </el-button>
            <!-- <el-button type="primary" v-hasPermit="['wms-warehouse:inventory:save']" icon="Plus" @click="ctx.showEdit()">
              添加
            </el-button> -->
          </span>
        </div>
      </template>
      <template #type="scope">
        {{ ctx.other.getTypeName(scope.row.type) }}
      </template>
      <template #disabled="scope">
        <el-switch v-model="scope.row.disabled" :active-value="false" :inactive-value="true"
          @change="ctx.other.statusChanged(scope.row)" />
      </template>
      <!-- <template #operation="scope">
        <el-button type="primary" v-hasPermit="['wms-warehouse:inventory:save']" link size="small" icon="Edit"
          @click="ctx.showEdit(scope.row)">
          编辑
        </el-button>
        <el-button v-hasPermit="['wms-warehouse:inventory:del']" type="danger" link size="small" icon="Delete"
          @click="ctx.del(scope.row.id)">
          删除
        </el-button>
      </template> -->
      <template #after>
        <el-dialog v-model="ctx.editVisible" :title="ctx.editAction + ctx.title" width="600px" append-to-body
          :close-on-click-modal="false" @close="ctx.closeEdit()">
          <el-form :ref="(e) => ctx.formRef = e" :model="ctx.editData" :rules="ctx.rules" v-loading="ctx.editLoading"
            label-width="120px" class="demo-ruleForm">
            <el-form-item label="仓库" prop="warehouseId">
              <el-select v-model="ctx.editData.warehouseId" placeholder="请选择仓库" @change="ctx.other.handleWarehouse">
                <el-option v-for="item in warehouseOptions" :key="item.id" :label="item.name" :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="货主" prop="ownerId">
                <el-select v-model="ctx.editData.ownerId" placeholder="请选择货主" @change="ctx.other.handleOwner">
                  <el-option v-for="item in ownerOptions" :key="item.id" :label="item.name" :value="item.id"></el-option>
                </el-select>
              </el-form-item> -->
            <el-form-item label="物料编码" prop="barCode">
              <el-input v-model="ctx.editData.barCode" placeholder="请输入物料编码" />
            </el-form-item>
            <el-form-item label="品名" prop="skuName">
              <el-input v-model="ctx.editData.skuName" placeholder="请输入品名" />
            </el-form-item>

            <el-form-item label="标号" prop="skuCode">
              <el-input v-model="ctx.editData.skuCode" placeholder="请输入标号" />
            </el-form-item>

            <el-form-item label="规格型号" prop="specification">
              <el-input v-model="ctx.editData.specification" placeholder="请输入规格型号" />
            </el-form-item>

            <el-form-item label="计量单位" prop="unit">
              <el-input v-model="ctx.editData.unit" placeholder="请输入计量单位" />
            </el-form-item>
            <el-form-item label="单价（¥）" prop="price">
              <el-input v-model="ctx.editData.price" placeholder="请输入单价（¥）" />
            </el-form-item>
            <el-form-item label="库存数量" prop="number">
              <el-input v-model="ctx.editData.number" placeholder="请输入数量" />
            </el-form-item>
          </el-form>
          <template #footer>
            <span class="dialog-footer">
              <el-button @click="ctx.editVisible = false">取消</el-button>
              <el-button type="primary" @click="ctx.save()">确定</el-button>
            </span>
          </template>
        </el-dialog>
      </template>
    </zlrt-table>
  </u-container-layout>
</template>

<script lang="ts" src="./inventory" />

<style lang="scss" scoped>

</style>
